#
#   __init__.py.py
#   journalismManger
#
#   Created by luoxh on 2019/8/15 - 15:16.
#   Copyright © 2019 luoxh. All rights reserved.
#
from src.model.home.news import News


class NewsListVM(dict):

    def __init__(self, news, news_type, **kwargs):
        super().__init__(**kwargs)
        self['id'] = str(news['id'])
        self['title'] = news['title']
        self['author'] = news['author']
        self['media_type'] = news['media_type']
        self['images'] = news['images']
        self['video_src'] = news['video_src']
        self['news_type'] = news_type['name']
        self['creation_date'] = news['creation_date'].strftime(format='%Y-%m-%d %H:%M:%S')


class NewsDetailVM(dict):
    def __init__(self, news: News, **kwargs):
        super().__init__(**kwargs)
        self['title'] = news['title']
        self['author'] = news['author']
        self['content'] = news['content']
        self['creation_date'] = news['creation_date'].strftime(format='%Y-%m-%d %H:%M:%S')


class NewsTypeVM(dict):

    def __init__(self, news_type, **kwargs):
        super().__init__(**kwargs)
        self['id'] = str(news_type['id'])
        self['name'] = news_type['name']
